package org.apache.database.enums;

import java.io.Serializable;
import java.util.List;

public enum  InsertActionEnum {
    BASE();
    private StringBuffer sql;

    InsertActionEnum() {

    }

    public InsertActionEnum init(){
        this.sql =new StringBuffer();
        this.sql.append("INSERT INTO");
        this.sql.append(" ");
        return this;
    }
    public InsertActionEnum withTableName(String tableName){

        this.sql.append(" "+tableName+" ");
        return this;
    }
    public String insert(List<String> fieldName, List<Serializable> value){
        sql.append("(");
        for (String s : fieldName) {
            sql.append(s);
            sql.append(",");
        }
        sql.deleteCharAt(sql.length()-1);
        sql.append(")");
        sql.append("VALUES(");
        for (Serializable serializable : value) {
            if (serializable instanceof String){
                sql.append("'"+serializable+"'");
            }else {
                sql.append(serializable);
            }
            sql.append(",");
        }
        sql.deleteCharAt(sql.length()-1);
        sql.append(")");
        return sql.toString();

    }
}
